﻿using System;
using System.Data;
using System.Collections.Generic;
using Chenxin.Lib.Business.Entity;
namespace Chenxin.Lib.Business.BLL
{
    /// <summary>
    /// 业务逻辑类ContractLackItemsInfo 的摘要说明。
    /// </summary>
    public class ContractLackItemsInfo
    {
        public ContractLackItemsInfo()
        { }
        #region  成员方法

        /// <summary>
        /// 是否存在该记录
        /// </summary>
        /// <param name="ContractId"></param>
        /// <returns></returns>
        public bool Exists(Guid ContractId)
        {
            return Chenxin.Lib.Business.DAL.ContractLackItemsInfo.Exists(ContractId);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(Chenxin.Lib.Business.Entity.ContractLackItemsInfo model)
        {
            Chenxin.Lib.Business.DAL.ContractLackItemsInfo.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Chenxin.Lib.Business.Entity.ContractLackItemsInfo model)
        {
            Chenxin.Lib.Business.DAL.ContractLackItemsInfo.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public void Delete(Guid ContractId)
        {

            Chenxin.Lib.Business.DAL.ContractLackItemsInfo.Delete(ContractId);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Chenxin.Lib.Business.Entity.ContractLackItemsInfo GetModel(Guid ContractId)
        {

            return Chenxin.Lib.Business.DAL.ContractLackItemsInfo.GetModel(ContractId);
        }

        public DataSet GetModelAndIntentionCode(Guid ContractId)
        {
            return Chenxin.Lib.Business.DAL.ContractLackItemsInfo.GetModelAndIntentionCode(ContractId);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return Chenxin.Lib.Business.DAL.ContractLackItemsInfo.GetList(strWhere);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Chenxin.Lib.Business.Entity.ContractLackItemsInfo> GetModelList(string strWhere)
        {
            DataSet ds = Chenxin.Lib.Business.DAL.ContractLackItemsInfo.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Chenxin.Lib.Business.Entity.ContractLackItemsInfo> DataTableToList(DataTable dt)
        {
            List<Chenxin.Lib.Business.Entity.ContractLackItemsInfo> modelList = new List<Chenxin.Lib.Business.Entity.ContractLackItemsInfo>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Chenxin.Lib.Business.Entity.ContractLackItemsInfo model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Chenxin.Lib.Business.Entity.ContractLackItemsInfo();
                    if (dt.Rows[n]["ContractId"].ToString() != "")
                    {
                        model.ContractId = new Guid(dt.Rows[n]["ContractId"].ToString());
                    }
                    if (dt.Rows[n]["IsLackItem1"].ToString() != "")
                    {
                        if ((dt.Rows[n]["IsLackItem1"].ToString() == "1") || (dt.Rows[n]["IsLackItem1"].ToString().ToLower() == "true"))
                        {
                            model.IsLackItem1 = true;
                        }
                        else
                        {
                            model.IsLackItem1 = false;
                        }
                    }
                    model.LackItems1 = dt.Rows[n]["LackItems1"].ToString();
                    model.LackOthers1 = dt.Rows[n]["LackOthers1"].ToString();
                    if (dt.Rows[n]["CompleteDate1"].ToString() != "")
                    {
                        model.CompleteDate1 = DateTime.Parse(dt.Rows[n]["CompleteDate1"].ToString());
                    }
                    if (dt.Rows[n]["IsLackItem2"].ToString() != "")
                    {
                        if ((dt.Rows[n]["IsLackItem2"].ToString() == "1") || (dt.Rows[n]["IsLackItem2"].ToString().ToLower() == "true"))
                        {
                            model.IsLackItem2 = true;
                        }
                        else
                        {
                            model.IsLackItem2 = false;
                        }
                    }
                    model.LackItems2 = dt.Rows[n]["LackItems2"].ToString();
                    model.LackOthers2 = dt.Rows[n]["LackOthers2"].ToString();
                    if (dt.Rows[n]["CompleteDate2"].ToString() != "")
                    {
                        model.CompleteDate2 = DateTime.Parse(dt.Rows[n]["CompleteDate2"].ToString());
                    }
                    if (dt.Rows[n]["Addtime"].ToString() != "")
                    {
                        model.Addtime = DateTime.Parse(dt.Rows[n]["Addtime"].ToString());
                    }
                    if (dt.Rows[n]["Updatetime"].ToString() != "")
                    {
                        model.Updatetime = DateTime.Parse(dt.Rows[n]["Updatetime"].ToString());
                    }
                    if (dt.Rows[n]["UpdatePersonId"].ToString() != "")
                    {
                        model.UpdatePersonId = new Guid(dt.Rows[n]["UpdatePersonId"].ToString());
                    }
                    model.UpdatePerson = dt.Rows[n]["UpdatePerson"].ToString();
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }

        #endregion  成员方法
    }
}

